package com.nercel.dsj.gksales.api.controller;

import com.nercel.dsj.gksales.model.ResponseResult;
import com.nercel.dsj.gksales.model.dto.CommonExcelExoprtParamsDTO;
import com.nercel.dsj.gksales.service.ExportService;
import com.nercel.dsj.gksales.util.ApiResultUtil;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags="导出")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ExportApiController extends BaseApiController{

	private final ExportService exportService;

	@PostMapping(value="/api/v1/export/excel")
	public ResponseResult exportExcel(@RequestBody CommonExcelExoprtParamsDTO data) {
		String filename = exportService.export(data.getTpl(), data.getName(), data.getData(), data.getStartIndex());
		return ApiResultUtil.success(filename);
	}

}
